<?php

/**
 * Created by PhpStorm.
 * User: Yieong
 * Date: 2017/7/3
 * Time: 下午3:51
 */
class PartnerService extends Service
{

    public static function indexHeader(){
        return array(
            'RecDate'       => array('text' => '日期'),
            'SID'           => array('text' => '服'),
            'PartnerID'     => array('text' => '伙伴ID'),
            'PartnerName'   => array('text' => '伙伴名称'),
            'JoinTimes'     => array('text' => '伙伴参赛次数', 'rule' => 'numeric'),
            'ALLJoinTimes'  => array('text' => '总参赛次数', 'rule' => 'numeric'),
            'JoinRate'      => array('text' => '参赛频率', 'rule' => 'numeric'),
        );
    }

    public static function indexData($params){
        $data = ModPartner::fightData($params);

        $server = empty($params['server']) ? 'ALL' : $params['server'];

        $partnerList = PubDict::dict('roma', 'partnerid');

        foreach($data as &$v){
            $v['RecDate']       = $params['time'];
            $v['SID']           = $server;
            $v['PartnerName']   = $partnerList[$v['PartnerID']];
            $v['JoinRate']      = number_format($v['JoinTimes'] / $v['ALLJoinTimes'] * 100, '2') . '%';
        }
        unset($v);

        return $data;
    }

}